﻿//----------------------------------------------------

#region 命名空间

//    版权：
//    作者：
//建立时间：2012-09-11 00:00:33
//    描述：
//----------------------------------------------------
using System;
using System.Data;
using System.Text;
using System.Collections.Generic;
using WinnerCMS.Data;
using System.Web.UI.WebControls;
using WinnerCMS.Model;
using WinnerCMS.Common;

#endregion

namespace WinnerCMS.BLL
{
    /// <summary>
    /// 业务逻辑类 WinnerCMS_OrderList 的摘要说明。
    /// </summary>
    public class OrderListManage
    {
        private static readonly OrderListDal MyDAL = new OrderListDal();

        #region 添加

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="cartGuid"></param>
        /// <param name="orderId"></param>
        /// <param name="remark"></param>
        public Result Add(string cartGuid, int orderId, string remark)
        {
            Result res = new Result();
            try
            {
                MyDAL.Add(cartGuid, orderId, remark);
            }
            catch (Exception ex)
            {
                res.Errors = ex.Message;
            }
            return res;
        }

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="goodsId"></param>
        /// <param name="orderId"></param>
        /// <param name="remark"></param>
        public Result Add(int goodsId, int orderId, string remark)
        {
            Result res = new Result();
            try
            {
                MyDAL.Add(goodsId, orderId, remark);
            }
            catch (Exception ex)
            {
                res.Errors = ex.Message;
            }
            return res;
        }

        #endregion

        #region  修改

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// <param name="strErr"></param>
        public void Edit(OrderList model, ref string strErr)
        {
            try
            {
                string adminName = UserManage.Current.UserName;
                string ip = HttpClient.GetIP();

                MyDAL.Edit(model, adminName, ip);
            }
            catch (Exception ex)
            {
                strErr = ex.Message;
            }
        }

        #endregion

        #region  加载数据

        /// <summary>
        /// 加载数据
        /// </summary>
        public OrderList GetInfo(int id)
        {
            return MyDAL.GetInfo(id);
        }

        #endregion

        /// <summary>
        /// 绑定数据
        /// </summary>
        /// <param name="orderId"></param>
        /// <returns></returns>
        public IList<OrderList> GetList(int orderId)
        {
            return MyDAL.BindList(orderId);
        }

        /// <summary>
        /// 统计
        /// </summary>
        /// <returns></returns>
        public void Rank(BaseDataBoundControl gvList, int type)
        {
            gvList.DataSource = MyDAL.Rank(type);
            gvList.DataBind();
        }
    }
}